
/**
 * @desc 商品批量分组
 * @author yd_zhaorongjun
 */
<template>
  <div>
    <el-dialog
      :title="title"
      class="gl_dialog_TitleLine gl_dl_footer"
      :visible.sync="dialogVisible"
      :close-on-click-modal="false"
      width="632px"
    >
      <el-scrollbar ref="scroll" v-loading="loading" wrap-class="scrollbar-wrapper">
        <el-form ref="Api_PUT_MallProductStatusListQO" class="gl_form_mini" :model="Api_PUT_MallProductStatusListQO" :rules="Api_POST_ProductGroup_Rules" label-position="top" label-width="120px" style="padding:0 30px">
          <el-row :gutter="20">
            <el-col :span="24">
              <el-form-item label="商品分组名称" prop="groupId">
                <el-select v-model="Api_PUT_MallProductStatusListQO.groupId" size="small" placeholder="请选择" style="width:100%">
                  <el-option v-for="item in productGroup" :key="item.id" :value="item.id" :label="item.name" />
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
      </el-scrollbar>

      <span slot="footer" class="dialog-footer">
        <!-- 取消按钮 -->
        <el-button size="mini" @click="dialogVisible = false">{{ $t('button.cancel') }}</el-button>
        <!-- 保存按钮 -->
        <el-button type="primary" :loading="submitLoading" size="mini" @click="saveNew()">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>
<script>
export default {
  props: {
    productGroup: {
      type: Array,
      default() {
        return [];
      }
    }
  },
  data() {
    return {
      Api_PUT_MallProductStatusListQO: {
        groupId: ''
      },
      Api_POST_ProductGroup_Rules: {
        groupId: [
          {
            required: true,
            message: '新选择商品分组',
            trigger: 'change'
          }
        ]
      },
      title: '批量分组',
      loading: false,
      groupId: '',
      submitLoading: false,
      dialogVisible: false
    };
  },
  watch: {
    dialogVisible(val) {
      if (!val) {
        this.$refs['Api_PUT_MallProductStatusListQO'].resetFields();
      }
    }
  },
  methods: {
    open() {
      this.loading = true;
      this.Api_PUT_MallProductStatusListQO.groupId = '';
      this.$nextTick(() => {
        this.dialogVisible = true;
        this.loading = false;
      });
    },
    // 新增
    saveNew() {
      this.$refs.Api_PUT_MallProductStatusListQO.validate(valid => {
        this.submitLoading = true;
        if (valid) {
          this.$emit('insert', this.Api_PUT_MallProductStatusListQO.groupId);
        } else {
          this.submitLoading = false;
          return false;
        }
      });
    }
  }
};
</script>
<style lang="scss" scoped>
  .tip_info_style {
    // padding: 0 10px 0 30px;
    font-size: 14px;
    color: #C0C4CC;
  }
  .personalUserInfo_img_wrap .el-form-item__error {
    padding-left: 10px;
  }
  .upload_game_img.no_pointer {
    cursor: default;
  }
  .upload_game_img {
    width: 102px;
    height: 96px;
    line-height: 94px;
    text-align: center;
    font-size: 20px;
    border: 1px dotted #DCDFE6;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
  }
  .upload_game_img .show_img {
    max-width: 100%;
    max-height: 100%;
    border-radius: 4px;
    vertical-align: middle;
  }
</style>
